const db = wx.cloud.database()
//const icloud = db.collection('Test')
const row = 8
Page({
  data: {
    //切换
    btns: ["科普文章", "科普实验", "科普乐趣"],
    active: 0,
    test1: [],
    artical: [],
    loadingFlag: '', //加载动画数组
  },
  //生命周期函数
  onLoad: function (options) {
    /* icloud.limit(row).get({
       success: res => {
         this.setData({
         test1: res.data,
         })
       }
     })*/
    db.collection('Articals').where({ //云数据库调用
        _openid: 'user01'
      })
      .get({
        success: res => {
          // res.data 是包含以上定义的两条记录的数组
          this.setData({
            artical: res.data,
          })
        }
      })
  },
  //跳转到科普文章
  gotoarticl: function (e) {
    //获取携带data-id的数据
    let D_id = e.currentTarget.dataset.id
    //携带ID进行页面跳转ß 
    wx.navigateTo({
      url: '/views/artical1/artical1?id=' + D_id,
    })
  },
  //功能列表切换
  change: function (e) {
    this.setData({
      active: e.currentTarget.dataset.index
    })
  },
})
